package com.zl.net
{
	import cn.skyclass.controls.AdvancedAlert;
	import cn.skyclass.net.URLUtilEx;
	
	import com.zl.event.CommonEvent;
	import com.zl.net.FileUploader;
	
	import flash.events.DataEvent;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.net.FileFilter;

	[Event(name="select", type="flash.events.Event")]
	[Event(name="transfer_data", type="com.zl.event.CommonEvent")]
	public class MeasureAnalyseExcelUploader extends FileUploader
	{
		public function MeasureAnalyseExcelUploader()
		{
			_fileFilterArray.push(new FileFilter("Excel文件", "*.xls;*.xlsx"));
		}
		
		public var fileName:String = '';
			
		override protected function onSelected(e:Event):void{
			super.onSelected(e);
			fileName = _fileReference.name;
			dispatchEvent(e);
		}
		override protected function onUploading(e:ProgressEvent):void{
			super.onUploading(e);
			
		}
		override protected function onUploadFailed(e:IOErrorEvent):void{
			super.onUploadFailed(e);
			AdvancedAlert.info("上传失败！");
		}
		override protected function onUploaded(e:DataEvent):void{
			super.onUploaded(e);
			var result:String = e.data;
			
			if(result == "fail"){
				AdvancedAlert.info("上传失败！");
			}else{
				dispatchEvent(new CommonEvent(CommonEvent.TRANSFER_DATA, result));
			}
		}
		
		override public function uploadFile():void{
			if(!_url){
				AdvancedAlert.info("上传地址出错！");
				return;
			}
			
			super.uploadFile();
		}
		
	}
}